﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;
using YArchitech.LIB;
using YArchitech.LIB.YJKControls;
using YArchitech.Revit;
using YJKArchMethodLibrary.Utils;
using YJKCodeBase.WinForm;
using YJKCodeBase.XmlUtility;
using YJKElementFinish.ColumnSurface.DataDefinition;
using YJKElementFinish.ColumnSurface.Managers;
using YJKRoomDecorate.Kit;
using RevitInteractiveUtility.ExternalEventManager;

namespace YJKRoomDecorate.Forms
{
	public partial class RoomDecorateForm : System.Windows.Forms.Form
	{
		public RoomDecorateForm(ExternalCommandData cmdData, WindowHandle _hWndRevit)
		{
			this.m_cmdData = cmdData;
			this.m_hWndRevit = _hWndRevit;
			this.m_doc = cmdData.Application.ActiveUIDocument.Document;
			this.InitializeComponent();
			string workingLocation = Product.WorkingLocation;
			string text = Path.Combine(workingLocation, "RoomDecorate");
			Directory.CreateDirectory(text);
			this.m_strXMLDefinePath = Path.Combine(text, "RoomDecorateSettingForm.xml");
			this.m_strSkirtlineFamilyTempDir = text;
			this.m_xmlHelper = new YJKCodeBase.XmlUtility.XmlHelper(this.m_strXMLDefinePath, "Root");
			this.m_defInfoForm = new RoomDecorateFormInfo(this.m_xmlHelper);
			foreach (WallTypeLayerInfos eleTypeDef in this.m_defInfoForm.MetopeTypeList)
			{
				WallType wallType = null;
				this.CreateWallType(ref wallType, eleTypeDef);
			}
			foreach (WallTypeLayerInfos eleTypeDef2 in this.m_defInfoForm.CeilingTypeList)
			{
				FloorType floorType = null;
				this.CreateCeilingType(ref floorType, eleTypeDef2);
			}
			foreach (WallTypeLayerInfos eleTypeDef3 in this.m_defInfoForm.GroundTypeList)
			{
				FloorType floorType2 = null;
				this.CreateGroundType(ref floorType2, eleTypeDef3);
			}
		}

		[DllImport("user32.dll", EntryPoint = "SendMessageA")]
		public static extern int SendMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);

		[DllImport("user32.dll")]
		public static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);

		private void CancelRevitOperate()
		{
			byte bVk = 27;
			int dwFlags = 0;
			int dwFlags2 = 2;
			RoomDecorateForm.keybd_event(bVk, 0, dwFlags, 0);
			RoomDecorateForm.keybd_event(bVk, 0, dwFlags2, 0);
		}

		private void SetFocusToRevit()
		{
			int wMsg = 7;
			RoomDecorateForm.SendMessage(this.m_hWndRevit.Handle, wMsg, IntPtr.Zero, IntPtr.Zero);
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			this.CancelRevitOperate();
			this.SetFocusToRevit();
			base.Close();
		}

		private void RoomDecorateForm_Load(object sender, EventArgs e)
		{
			//base.Icon = Resource.YArchitechIcon;
			base.Location = new System.Drawing.Point(this.m_defInfoForm.FormXPos, this.m_defInfoForm.FormYPos);
			this.m_lstMetopeType = DrawDecorateEnt.GetMetopeType(this.m_doc);
			this.m_lstGroundType = DrawDecorateEnt.GetGroundType(this.m_doc);
			this.m_lstCeilingType = DrawDecorateEnt.GetCeilingType(this.m_doc);
			this.InitTypeList(this.cmbMetopeType, this.m_lstMetopeType, this.m_defInfoForm.DefaultNameMetope);
			this.InitTypeList(this.cmbGroundType, this.m_lstGroundType, this.m_defInfoForm.DefaultNameGround);
			this.InitTypeList(this.cmbCeilingType, this.m_lstCeilingType, this.m_defInfoForm.DefaultNameCeiling);
			this.InitSkirtlineTypeList(this.m_defInfoForm.DefaultNameSkirtline);
			this.InitFormInfo();
			this.InitExternalEventRequest();
			this.SetFocusToRevit();
			this.DoIt();
		}

        private void InitTypeList(System.Windows.Forms.ComboBox cmbList, List<Element> lstEleType, string strTypeName = "")
		{
			cmbList.Items.Clear();
			if (lstEleType == null || lstEleType.Count == 0)
			{
				return;
			}
			List<string> list = new List<string>();
			for (int i = 0; i < lstEleType.Count; i++)
			{
				Element elementType = lstEleType[i];
				string elementTypeName = this.GetElementTypeName(elementType);
				list.Add(elementTypeName);
			}
			this.ManageDefaultListType(ref list, strTypeName);
			foreach (string item in list)
			{
				cmbList.Items.Add(item);
			}
			int selectedIndex = 0;
			cmbList.SelectedIndex = selectedIndex;
		}

		private string GetElementTypeName(Element elementType)
		{
            Autodesk.Revit.DB.ElementType elementType2 = elementType as Autodesk.Revit.DB.ElementType;
			if (elementType2 == null)
			{
				return "";
			}
			return elementType2.Name;
		}

		private void ManageDefaultListType(ref List<string> lstTypeName, string strTypeNameArray)
		{
			if (strTypeNameArray.IsEmpty<char>())
			{
				return;
			}
			List<string> list = strTypeNameArray.Split(new char[]
			{
				';'
			}).ToList<string>();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].IsEmpty<char>())
				{
					list.RemoveAt(i);
					i--;
				}
				if (lstTypeName.Contains(list[i]))
				{
					lstTypeName.RemoveAt(lstTypeName.IndexOf(list[i]));
				}
				else
				{
					list.RemoveAt(i);
					i--;
				}
			}
			list.AddRange(lstTypeName);
			lstTypeName.Clear();
			lstTypeName.AddRange(list);
		}

		private void InitSkirtlineTypeList(string strDefaultTypeName = "")
		{
			this.cmbSkirtlineType.Items.Clear();
			string text = Path.Combine(Product.FamilyLocation, RevitVersion.Version, "RoomDecorate", RoomDecorateForm.g_TiJiao + RoomDecorateForm.g_FamilyFileExt);
			if (File.Exists(text))
			{
				string destFileName = this.m_strSkirtlineFamilyTempDir + "\\" + RoomDecorateForm.g_TiJiao + RoomDecorateForm.g_FamilyFileExt;
				File.Copy(text, destFileName, true);
			}
			List<string> list = new List<string>();
			if (!this.m_defInfoForm.SkirtlineNameList.Contains(RoomDecorateForm.g_TiJiao))
			{
				this.m_defInfoForm.SkirtlineNameList.Add(RoomDecorateForm.g_TiJiao);
			}
			foreach (string text2 in this.m_defInfoForm.SkirtlineNameList)
			{
				string strFamilyFilePath = this.m_strSkirtlineFamilyTempDir + "\\" + text2 + RoomDecorateForm.g_FamilyFileExt;
				List<string> listSkirtlineName = DrawDecorateEnt.GetListSkirtlineName(text2, strFamilyFilePath, this.m_doc);
				if (listSkirtlineName != null && listSkirtlineName.Count > 0)
				{
					foreach (string item in listSkirtlineName)
					{
						list.Add(item);
					}
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			this.ManageDefaultListType(ref list, strDefaultTypeName);
			foreach (string item2 in list)
			{
				this.cmbSkirtlineType.Items.Add(item2);
				if (this.cmbCeilingType.Items.Count > this.m_nTopPos10)
				{
					break;
				}
			}
			this.cmbSkirtlineType.SelectedIndex = 0;
		}

		private void InitExternalEventRequest()
		{
			ExternalEventManagerSingleton eventManger = ExternalEventManagerSingleton.GetEventManger(false);
			int iRequestId = 1;
			this.m_Request = new RoomDecorateFormRequest(iRequestId);
			eventManger.AppendRequest(this.m_Request);
		}

		public void DoIt()
		{
			ExternalEventManagerSingleton eventManger = ExternalEventManagerSingleton.GetEventManger(false);
			int keyValue = 1;
			eventManger.DoRequest(keyValue, this.m_cmdData.Application, this);
		}

		private void RoomDecorateForm_FormClosed(object sender, FormClosedEventArgs e)
		{
			this.SaveFormInfo();
			this.CancelRevitOperate();
			this.SetFocusToRevit();
		}

		private void RoomDecorateForm_MouseLeave(object sender, EventArgs e)
		{
			if (!base.ClientRectangle.Contains(base.PointToClient(Cursor.Position)))
			{
				this.SetFocusToRevit();
				return;
			}
			base.Focus();
		}

		private void btnSetLayerMetope_Click(object sender, EventArgs e)
		{
			List<CompoundStructureLayer> lstLayers = new List<CompoundStructureLayer>();
			string strWallTypeName = "装饰墙1";
			if (!this.GetElementTypeLayers(ref strWallTypeName, ref lstLayers, this.m_lstMetopeType))
			{
				return;
			}
			WallType wallType = DrawDecorateEnt.CreateWallTypeInner(strWallTypeName, lstLayers, this.m_doc, true);
			if (wallType == null)
			{
				return;
			}
			this.m_lstMetopeType.Add(wallType);
			string elementTypeName = this.GetElementTypeName(wallType);
			this.cmbMetopeType.Items.Insert(0, elementTypeName);
			this.cmbMetopeType.SelectedIndex = 0;
			WallTypeLayerInfos wallLayerInfoListByType = WallTypeManager.GetWallLayerInfoListByType(wallType, this.m_doc);
			this.m_defInfoForm.MetopeTypeList.Insert(0, wallLayerInfoListByType);
		}

		private void GetTypeLayers(ref List<CompoundStructureLayer> lstLayers, WallTypeLayerInfos eleType)
		{
			foreach (WallLayerInfos wallLayerInfos in eleType.LayerList)
			{
				double num = Common.MMToFeet(wallLayerInfos.Thickness.ToDouble(0.0));
				MaterialFunctionAssignment layerMaterialFunctionByName = WallTypeManager.GetLayerMaterialFunctionByName(wallLayerInfos.Name);
				ElementId materialIdByName = WallTypeManager.GetMaterialIdByName(wallLayerInfos.MaterialName, this.m_doc);
				CompoundStructureLayer item = new CompoundStructureLayer(num, layerMaterialFunctionByName, materialIdByName);
				lstLayers.Add(item);
			}
		}

		private bool CreateWallType(ref WallType eleType, WallTypeLayerInfos eleTypeDef)
		{
			List<CompoundStructureLayer> list = new List<CompoundStructureLayer>();
			this.GetTypeLayers(ref list, eleTypeDef);
			if (list.Count == 0)
			{
				return false;
			}
			eleType = DrawDecorateEnt.CreateWallTypeInner(eleTypeDef.TypeName, list, this.m_doc, false);
			return eleType != null;
		}

		private bool CreateCeilingType(ref FloorType eleType, WallTypeLayerInfos eleTypeDef)
		{
			List<CompoundStructureLayer> list = new List<CompoundStructureLayer>();
			this.GetTypeLayers(ref list, eleTypeDef);
			if (list.Count == 0)
			{
				return false;
			}
			eleType = DrawDecorateEnt.CreateCeilingType(eleTypeDef.TypeName, list, this.m_doc, false);
			return eleType != null;
		}

		private bool CreateGroundType(ref FloorType eleType, WallTypeLayerInfos eleTypeDef)
		{
			List<CompoundStructureLayer> list = new List<CompoundStructureLayer>();
			this.GetTypeLayers(ref list, eleTypeDef);
			if (list.Count == 0)
			{
				return false;
			}
			eleType = DrawDecorateEnt.CreateGroundType(eleTypeDef.TypeName, list, this.m_doc, false);
			return eleType != null;
		}

		private bool GetElementTypeLayers(ref string strTypeName, ref List<CompoundStructureLayer> lstLayers, List<Element> lstElementType)
		{
			List<WallLayerInfos> wallTypeLayerInfos = this.CreateWallLayerInfosList();
			RoomDecorateEntStructureForm roomDecorateEntStructureForm = new RoomDecorateEntStructureForm(this.m_doc, wallTypeLayerInfos, lstElementType);
			roomDecorateEntStructureForm.m_strTypeName = strTypeName;
			if (roomDecorateEntStructureForm.ShowDialog() != DialogResult.OK)
			{
				return false;
			}
			List<WallLayerInfos> wallLayerInfo = roomDecorateEntStructureForm.WallLayerInfo;
			foreach (WallLayerInfos wallLayerInfos in wallLayerInfo)
			{
				lstLayers.Add(wallLayerInfos.StructureLayer);
			}
			strTypeName = roomDecorateEntStructureForm.m_strTypeName;
			return true;
		}

		private List<WallLayerInfos> CreateWallLayerInfosList()
		{
			List<WallLayerInfos> list = new List<WallLayerInfos>();
			double val = 20.0;
			double num = Common.MMToFeet(val);
            MaterialFunctionAssignment materialFunctionAssignment = (MaterialFunctionAssignment)4;
			ElementId invalidElementId = ElementId.InvalidElementId;
			CompoundStructureLayer structureLayer = new CompoundStructureLayer(num, materialFunctionAssignment, invalidElementId);
			string layerNameByMaterialFunction = WallTypeManager.GetLayerNameByMaterialFunction(materialFunctionAssignment);
			WallLayerInfos item = new WallLayerInfos(structureLayer, layerNameByMaterialFunction, "按类别", val.ToString());
			list.Add(item);
			return list;
		}

		private void btnSetLayerCeiling_Click(object sender, EventArgs e)
		{
			List<CompoundStructureLayer> lstLayers = new List<CompoundStructureLayer>();
			string strTypeName = "天花板1";
			if (!this.GetElementTypeLayers(ref strTypeName, ref lstLayers, this.m_lstCeilingType))
			{
				return;
			}
			FloorType floorType = DrawDecorateEnt.CreateCeilingType(strTypeName, lstLayers, this.m_doc, true);
			if (floorType == null)
			{
				return;
			}
			this.m_lstCeilingType.Add(floorType);
			string elementTypeName = this.GetElementTypeName(floorType);
			this.cmbCeilingType.Items.Insert(0, elementTypeName);
			this.cmbCeilingType.SelectedIndex = 0;
			WallTypeLayerInfos wallLayerInfoListByType = WallTypeManager.GetWallLayerInfoListByType(floorType, this.m_doc);
			this.m_defInfoForm.CeilingTypeList.Insert(0, wallLayerInfoListByType);
		}

		private void btnSetLayerGround_Click(object sender, EventArgs e)
		{
			List<CompoundStructureLayer> lstLayers = new List<CompoundStructureLayer>();
			string strTypeName = "楼地面1";
			if (!this.GetElementTypeLayers(ref strTypeName, ref lstLayers, this.m_lstGroundType))
			{
				return;
			}
			FloorType floorType = DrawDecorateEnt.CreateGroundType(strTypeName, lstLayers, this.m_doc, true);
			if (floorType == null)
			{
				return;
			}
			this.m_lstGroundType.Add(floorType);
			string elementTypeName = this.GetElementTypeName(floorType);
			this.cmbGroundType.Items.Insert(0, elementTypeName);
			this.cmbGroundType.SelectedIndex = 0;
			WallTypeLayerInfos wallLayerInfoListByType = WallTypeManager.GetWallLayerInfoListByType(floorType, this.m_doc);
			this.m_defInfoForm.GroundTypeList.Insert(0, wallLayerInfoListByType);
		}

		public static string GetDefaultDir(UIApplication uiApp)
		{
			string text = "";
			uiApp.Application.GetLibraryPaths();
			uiApp.Application.GetLibraryPaths().TryGetValue("Metric Library", out text);
			if (!string.IsNullOrEmpty(text))
			{
				text = Path.Combine(text, "轮廓");
			}
			return text;
		}

		private void btnSetLayerSkirtline_Click(object sender, EventArgs e)
		{
			OpenFileDialog openFileDialog = new OpenFileDialog();
			openFileDialog.Multiselect = true;
			openFileDialog.Title = "请选择轮廓族文件";
			openFileDialog.Filter = "所有文件(*.rfa)|*.rfa";
			openFileDialog.InitialDirectory = RoomDecorateForm.GetDefaultDir(this.m_cmdData.Application);
			if (openFileDialog.ShowDialog() == DialogResult.OK)
			{
				foreach (string text in openFileDialog.FileNames)
				{
					string text2 = Path.GetFileNameWithoutExtension(text);
					if (!DrawDecorateEnt.IsValidSweepProfileCategory(text, this.m_doc))
					{
						YJKMessageBox.Show("不是有效的轮廓族!");
					}
					else
					{
						string text3 = this.m_strSkirtlineFamilyTempDir + "\\" + text2 + RoomDecorateForm.g_FamilyFileExt;
						if (!File.Exists(text3))
						{
							File.Copy(text, text3, false);
						}
						if (!this.m_defInfoForm.SkirtlineNameList.Contains(text2))
						{
							this.m_defInfoForm.SkirtlineNameList.Insert(0, text2);
							while (this.m_defInfoForm.SkirtlineNameList.Count<string>() > this.m_nTopPos10)
							{
								text2 = this.m_defInfoForm.SkirtlineNameList[this.m_defInfoForm.SkirtlineNameList.Count<string>() - 1];
								text3 = this.m_strSkirtlineFamilyTempDir + "\\" + text2 + RoomDecorateForm.g_FamilyFileExt;
								File.Delete(text3);
							}
						}
					}
				}
				this.InitSkirtlineTypeList("");
			}
		}

		private void InitFormInfo()
		{
			this.chkMetope.Checked = this.m_defInfoForm.IncludeMetope;
			this.chkMetopeToCeiling.Checked = this.m_defInfoForm.MetopeTopToCeiling;
			this.chkIncludeColumn.Checked = this.m_defInfoForm.MetopeIncludeColumn;
			this.chkCeiling.Checked = this.m_defInfoForm.IncludeCeiling;
			this.chkGround.Checked = this.m_defInfoForm.IncludeGround;
			this.chkSkirtline.Checked = this.m_defInfoForm.IncludeSkirtline;
			this.txtHighMetope.Text = this.m_defInfoForm.DefaultHighMetope.ToString("f0");
			this.txtHighCeiling.Text = this.m_defInfoForm.DefaultHighCeiling.ToString("f0");
			this.txtHighGround.Text = this.m_defInfoForm.DefaultHighGround.ToString("f0");
			this.txtMetopeBottomOffset.Text = this.m_defInfoForm.DefaultMetopeBottomOffset.ToString("f0");
			this.txtHighMetope.Enabled = !this.chkMetopeToCeiling.Checked;
			this.InitMetopeCheckStatus();
			this.InitSkirtlineCheckStatus();
			this.InitCeilingCheckStatus();
			this.InitGroundCheckStatus();
		}

		public void SaveFormInfo()
		{
			this.m_defInfoForm.FormXPos = base.Location.X;
			this.m_defInfoForm.FormYPos = base.Location.Y;
			this.m_defInfoForm.IncludeMetope = this.chkMetope.Checked;
			this.m_defInfoForm.MetopeTopToCeiling = this.chkMetopeToCeiling.Checked;
			this.m_defInfoForm.MetopeIncludeColumn = this.chkIncludeColumn.Checked;
			this.m_defInfoForm.IncludeCeiling = this.chkCeiling.Checked;
			this.m_defInfoForm.IncludeGround = this.chkGround.Checked;
			this.m_defInfoForm.IncludeSkirtline = this.chkSkirtline.Checked;
			this.m_defInfoForm.DefaultHighMetope = this.txtHighMetope.Text.ToDouble(0.0);
			this.m_defInfoForm.DefaultHighCeiling = this.txtHighCeiling.Text.ToDouble(0.0);
			this.m_defInfoForm.DefaultHighGround = this.txtHighGround.Text.ToDouble(0.0);
			this.m_defInfoForm.DefaultMetopeBottomOffset = this.txtMetopeBottomOffset.Text.ToDouble(0.0);
			this.m_defInfoForm.DefaultNameMetope = this.GetDefaultTypeList(this.cmbMetopeType);
			this.m_defInfoForm.DefaultNameCeiling = this.GetDefaultTypeList(this.cmbCeilingType);
			this.m_defInfoForm.DefaultNameGround = this.GetDefaultTypeList(this.cmbGroundType);
			this.m_defInfoForm.DefaultNameSkirtline = this.GetDefaultTypeList(this.cmbSkirtlineType);
			this.m_defInfoForm.Save();
		}

        private string GetDefaultTypeList(System.Windows.Forms.ComboBox cmbList)
		{
			string result = "";
			int selectedIndex = cmbList.SelectedIndex;
			if (selectedIndex < 0)
			{
				return result;
			}
			List<string> list = new List<string>();
			for (int i = 0; i < cmbList.Items.Count; i++)
			{
				string item = cmbList.Items[i].ToString();
				if (i == selectedIndex)
				{
					list.Insert(0, item);
				}
				else
				{
					list.Add(item);
				}
			}
			return string.Join(";", list.ToArray());
		}

        public Autodesk.Revit.DB.ElementType GetSelectElementType(System.Windows.Forms.ComboBox cmbList, List<Element> lstElementType)
		{
			int selectedIndex = cmbList.SelectedIndex;
			if (selectedIndex < 0)
			{
				return null;
			}
			string a = cmbList.Items[selectedIndex].ToString();
			for (int i = 0; i < lstElementType.Count; i++)
			{
				Element element = lstElementType[i];
                Autodesk.Revit.DB.ElementType elementType = element as Autodesk.Revit.DB.ElementType;
				string elementTypeName = this.GetElementTypeName(elementType);
				if (a == elementTypeName)
				{
					return elementType;
				}
			}
			return null;
		}

        public Autodesk.Revit.DB.ElementType GetSelectElementTypeMetope()
		{
			return this.GetSelectElementType(this.cmbMetopeType, this.m_lstMetopeType);
		}

        public Autodesk.Revit.DB.ElementType GetSelectElementTypeGround()
		{
			return this.GetSelectElementType(this.cmbGroundType, this.m_lstGroundType);
		}

        public Autodesk.Revit.DB.ElementType GetSelectElementTypeCeiling()
		{
			return this.GetSelectElementType(this.cmbCeilingType, this.m_lstCeilingType);
		}

		public FamilySymbol GetSelectElementTypeSkirtline()
		{
			int selectedIndex = this.cmbSkirtlineType.SelectedIndex;
			if (selectedIndex < 0)
			{
				return null;
			}
			string strSelTypeName = this.cmbSkirtlineType.Items[selectedIndex].ToString();
			foreach (string text in this.m_defInfoForm.SkirtlineNameList)
			{
				string strFamilyFilePath = this.m_strSkirtlineFamilyTempDir + "\\" + text + RoomDecorateForm.g_FamilyFileExt;
				FamilySymbol skirtlineFamilyTypeFromName = DrawDecorateEnt.GetSkirtlineFamilyTypeFromName(strSelTypeName, text, strFamilyFilePath, this.m_doc);
				if (skirtlineFamilyTypeFromName != null)
				{
					return skirtlineFamilyTypeFromName;
				}
			}
			return null;
		}

		private void chkMetopeToCeiling_CheckedChanged(object sender, EventArgs e)
		{
			this.txtHighMetope.Enabled = !this.chkMetopeToCeiling.Checked;
			this.CalMetopeHigh();
		}

		private void chkMetope_CheckedChanged(object sender, EventArgs e)
		{
			this.InitSkirtlineCheckStatus();
			this.InitMetopeCheckStatus();
		}

		private void chkCeiling_CheckedChanged(object sender, EventArgs e)
		{
			this.InitCeilingCheckStatus();
		}

		private void chkGround_CheckedChanged(object sender, EventArgs e)
		{
			this.InitGroundCheckStatus();
		}

		private void chkSkirtline_CheckedChanged(object sender, EventArgs e)
		{
			this.InitSkirtlineCheckStatus();
		}

		private void InitSkirtlineCheckStatus()
		{
			bool enabled = this.chkMetope.Checked && this.chkSkirtline.Checked;
			this.chkSkirtline.Enabled = this.chkMetope.Checked;
			this.cmbSkirtlineType.Enabled = enabled;
			this.btnSetLayerSkirtline.Enabled = enabled;
		}

		private void InitCeilingCheckStatus()
		{
			bool @checked = this.chkCeiling.Checked;
			this.cmbCeilingType.Enabled = @checked;
			this.btnSetLayerCeiling.Enabled = @checked;
			this.txtHighCeiling.Enabled = @checked;
		}

		private void InitGroundCheckStatus()
		{
			bool @checked = this.chkGround.Checked;
			this.cmbGroundType.Enabled = @checked;
			this.btnSetLayerGround.Enabled = @checked;
			this.txtHighGround.Enabled = @checked;
		}

		private void InitMetopeCheckStatus()
		{
			bool @checked = this.chkMetope.Checked;
			this.cmbMetopeType.Enabled = @checked;
			this.btnSetLayerMetope.Enabled = @checked;
			this.txtHighMetope.Enabled = @checked;
			this.txtMetopeBottomOffset.Enabled = @checked;
			this.chkMetopeToCeiling.Enabled = @checked;
			this.chkIncludeColumn.Enabled = @checked;
			if (@checked)
			{
				this.txtHighMetope.Enabled = !this.chkMetopeToCeiling.Checked;
			}
		}

		private void txtHighCeiling_TextChanged(object sender, EventArgs e)
		{
			this.CalMetopeHigh();
		}

		private void txtMetopeBottomOffset_TextChanged(object sender, EventArgs e)
		{
			this.CalMetopeHigh();
		}

		private void CalMetopeHigh()
		{
			if (!this.txtHighMetope.Enabled)
			{
				double num = this.txtHighCeiling.Text.ToDouble(0.0) - this.txtMetopeBottomOffset.Text.ToDouble(0.0);
				if (num > 0.0)
				{
					this.txtHighMetope.Text = num.ToString();
				}
			}
		}

		private void RoomDecorateForm_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\u001b')
			{
				base.Close();
			}
		}

		public ExternalCommandData m_cmdData;

		private Document m_doc;

		private RoomDecorateFormRequest m_Request;

		private WindowHandle m_hWndRevit;

		private List<Element> m_lstMetopeType;

		private List<Element> m_lstGroundType;

		private List<Element> m_lstCeilingType;

		public List<Element> m_lstSelRooms;

		private string m_strXMLDefinePath;

		private string m_strSkirtlineFamilyTempDir;

		private YJKCodeBase.XmlUtility.XmlHelper m_xmlHelper;

		public RoomDecorateFormInfo m_defInfoForm;

		public static string g_FamilyFileExt = ".rfa";

		public static string g_TiJiao = "踢脚";

		private int m_nTopPos10 = 10;

		private enum ERequestId
		{
			eNoOper,
			eTransactionDecorateRoom
		}
	}
}
